package algorithm.poj.p1000;

import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * id: 1013
 * @author wong.tong@gmail.com
 *
 */
public class P1013 {

	public static void main(String[] args) throws Exception {
    	
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));

        String line;
        int n;
        String[] ps;
        String s = "";

        line = stdin.readLine();
        n = Integer.valueOf(line.trim());
        for (int i = 0; i < n; i ++) {
            ps = new String[] {stdin.readLine(), stdin.readLine(), stdin.readLine()};
            s += counterfeitDollar(ps) + "\n";
        }
        System.out.println(s);
	}

	private static String counterfeitDollar(String[] ps) {
		
		int[] w = new int[12];
		for (int i = 0; i < 12; i ++) {
			for (int j = 0; j < 12; j ++) {
				if (j == i) {
					w[j] = 9;
				} else {
					w[j] = 10;
				}
			}
			if (check(ps, w)) {
				return (char)('A'+i) + " is the counterfeit coin and it is light.";
			}
			for (int j = 0; j < 12; j ++) {
				if (j == i) {
					w[j] = 11;
				} else {
					w[j] = 10;
				}
			}
			if (check(ps, w)) {
				return (char)('A'+i) + " is the counterfeit coin and it is heavy.";
			}
		}
		return null;
	}
	
	private static boolean check(String ps[], int[] w) {
		
		for (int i = 0; i < ps.length; i ++) {
			String[] p = ps[i].split("\\s+");
			int lw = 0;
			for (int j = 0; j < p[0].length(); j ++) {
				lw += w[p[0].charAt(j)-'A'];
			}
			int rw = 0;
			for (int j = 0; j < p[1].length(); j ++) {
				rw += w[p[1].charAt(j)-'A'];
			}
			if ((lw > rw && !p[2].equalsIgnoreCase("up"))
					|| (lw == rw && !p[2].equalsIgnoreCase("even"))
					|| (lw < rw && !p[2].equalsIgnoreCase("down"))) {
				return false;
			}
		}
		return true;
	}
}
